import time

from selenium.webdriver.common.by import By


class  RegisterOperation:

    def register(self,driver,username,password1,password2):
        # 进入注册页面
        driver.find_element(By.XPATH, "//div[@style='margin-left: 100px']/a").click()
        time.sleep(1)
        # 输入用户名
        driver.find_element(By.XPATH, "//input[@id='username']").send_keys(username)
        time.sleep(1)
        # 输入密码
        driver.find_element(By.XPATH, "//input[@id='password']").send_keys(password1)
        time.sleep(1)
        # 输入重复密码
        driver.find_element(By.XPATH, "//input[@id='repassword']").send_keys(password2)
        time.sleep(1)
        #点击注册
        driver.find_element(By.XPATH, "//button[@id='login_btn']").click()
        time.sleep(1)

    #  获取实际结果
    def getResult(self,driver):
        # 获取页面标题
        title = driver.title
        # 判断是否注册成功
        if title == "个人理财系统注册界面":
            result = "注册失败"
        else:
            result = "注册成功"
        return result